package com.atguigu.jxc.service.impl;

import com.atguigu.jxc.dao.GoodsDao;
import com.atguigu.jxc.entity.Goods;
import com.atguigu.jxc.service.GoodsService;
import org.apache.shiro.crypto.hash.Hash;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class GoodsServiceImpl implements GoodsService {


    @Autowired
    private GoodsDao goodsDao;
    //带分页的查询条件的商品显示

    @Override
    public Map<String, Object> listInventory(Integer page, Integer rows, String codeOrName, Integer goodsTypeId) {
        Map<String,Object> map = new HashMap<>();
        page = page<1? 0: page-1;
        page = (page-1)*rows;
        //查询goods列表
        List<Goods> goodsList = goodsDao.getListGoods(page, rows,codeOrName,goodsTypeId);

        map.put("total", goodsList.size());

        map.put("rows", goodsList);

        return map;
    }
}